Component({
  properties: {
    percentage: {
      type: Number,
      value: 0,
    },
    time: {
      type: Number,
      value: 0
    }
  },

  data: {
    // 组件内部数据
    finishTime: false,
    confirmBtn: {
      content: '知道了',
      variant: 'base'
    },
    setList: ['SET:01;@', 'SET:02;@'],
    setListIndex: 0,
  },

  methods: {
    studyFn() {
      this.triggerEvent('studyFn', this.data.setList[this.data.setListIndex])
    },
    closeDialog() {
      this.setData({
        tipVisible: false,
      })
    },
    // finish(){
    //   this.setData({
    //     finishTime:true
    //   })
    // },
    finishStudyFn(cmd,params) {
      if (cmd == 'SET:03'&&params[0]=='01'&&params[1]=='OK') {
        //仰卧信息学习完毕
        this.setData({
          finishTime: false,
          tipVisible: true,
          tipCon: '仰卧信息学习完毕,请转为侧卧，肩部压在睡姿传感器上，然后点击“开始”',
          setListIndex: 1,
        })
      } else if (cmd == 'SET:02'&&params[0]=='01'&&params[1]=='OK') {
        // 侧卧信息学习完毕
        this.setData({
          finishTime: false,
          tipVisible: true,
          tipCon: '恭喜您完成了睡姿学习，智能枕能更精准地识别您的睡姿了',
          setListIndex: 0,
        })
      }
    },
    studyChildFn(cmdList) {
      let {cmd,params} = cmdList;
      //正在记录仰卧数据
      if (cmd == 'SET:02') {
        this.setData({
          conuntDownTime: 5 * 1000,
          finishTime: true
        },()=>{
          this.finishStudyFn(cmd,params);
        })
      } else if (cmd == 'SET:03') { //数据记录完成
        this.setData({
          conuntDownTime: 5 * 1000,
          finishTime: true
        })
        this.finishStudyFn(cmd,params);
      }
    },
  }
})